package cn.orangeframe.neon.application.run.async;

import cn.orangeframe.neon.application.tasks.WorkflowSystemTask;
import cn.orangeframe.neon.domain.entity.WorkflowTask;
import cn.orangeframe.neon.domain.model.TaskModel;
import cn.orangeframe.neon.domain.model.WorkflowModel;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

@Component
public class AsyncPublish {

    private final ApplicationEventPublisher publisher;

    public AsyncPublish(ApplicationEventPublisher publisher) {
        this.publisher = publisher;
    }

    public void publishAsyncTaskExecute(Object source, WorkflowSystemTask systemTask, WorkflowModel workflowModel, TaskModel taskModel) {
        AsyncTaskExecuteEvent executeEvent = new AsyncTaskExecuteEvent(source, systemTask, workflowModel, taskModel);
        publisher.publishEvent(executeEvent);
    }
}
